<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>首页</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../static/css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../static/css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../static/css/app.css" />
	</head>

	<body>
		<!--下拉刷新容器-->
		<!-- <div id="homepage" class="mui-content mui-scroll-wrapper"> -->
<!-- 		<div class="mui-navbar-inner mui-bar mui-bar-nav">
			<h1 class="mui-center mui-title">首页</h1>
		</div> -->
			<header class="mui-bar mui-bar-nav" style="height: 55px;">
				<!-- <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a> -->
				<h1 class="mui-title">首页</h1>
			</header>
			<div class="mui-scroll" style="margin-top: 50px">
				<!--数据列表-->
				<!--首页滚动栏-->
				<div id="slider" class="mui-slider">
					<div class="mui-slider-group mui-slider-loop">
						{{$len := .PicturesLen}}
						{{$startpic := .StartPic}}
						{{$endpic := .Endpic}}

						{{range $k, $v := .Pictures}}
							<!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
							{{if eq $k 0}}
								<div class="mui-slider-item mui-slider-item-duplicate">
									<a href="{{$endpic.Tourl}}">
										<img src="{{$endpic.Imgsrc}}">
									</a>
								</div>
							{{end}}
							<!-- 数据库读取的每张图片数据 -->
							<div class="mui-slider-item">
								<a href="{{$v.Tourl}}">
									<img src="{{$v.Imgsrc}}">
								</a>
							</div>

							<!-- 额外增加的一个节点(循环轮播：最后一个节点是第一张轮播) -->
							{{if eq $k $len}}
								<div class="mui-slider-item mui-slider-item-duplicate">
									<a href="{{$startpic.Tourl}}">
											<img src="{{$startpic.Imgsrc}}">
									</a>
								</div>
							{{end}}
						{{end}}
					</div>
					<div class="mui-slider-indicator">
						{{range $k,$v := .Pictures}}
							{{if eq $k 0}}
								<div class="mui-indicator mui-active"></div>
							{{else}}
								<div class="mui-indicator"></div>
							{{end}}
						{{end}}
					</div>
				</div>

				<!--选项grid-->
				<div class="mui-content">
					<ul id="opview" class="mui-table-view mui-grid-view mui-grid-9"style="background-color: ghostwhite;margin-top: 10px;">
						<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3">
							<a href="#">
								<span class="mui-icon iconfont icon-xinpin"></span>
								<h6>新品</h6>
							</a>
						</li>
						<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3">
							<a href="#">
								<span class="mui-icon iconfont icon-tehui"></span>
								<h6>每日特惠</h6>
							</a>
						</li>
						<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3">
							<a href="#">
								<span class="mui-icon iconfont icon-qiandao1"></span>
								<h6>签到</h6>
							</a>
						</li>
						<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3">
							<a href="#">
								<span class="mui-icon iconfont icon-youhuiquan2"></span>
								<h6>领券</h6>
							</a>
						</li>
					</ul>
				</div>

				<!--产品推荐-->
				<div class="title">
					<h4>精品推荐</h4>
				</div>
				<ul id="bestview" class="mui-table-view">
					{{range .Carousels}}
						<li class="mui-table-view-cell" style="padding: 5px;">
							<a href=""><img src="{{.Imgsrc}}" alt="" /></a>
						</li>
					{{end}}
				</ul>

				<!--展示-->
				<div class="title">
					<h4>热卖商品</h4>
				</div>
				<div class="mui-content">
					<ul id="hotview" class="mui-table-view mui-grid-view">
						{{range .Showlists}}
							<li class="mui-table-view-cell mui-media mui-col-xs-6">
								<!-- <a href="http://192.168.80.105:8080/buypage"><img src="{{.Imgsrc}}" alt="" class="mui-media-object" /></a> -->
								<a id="{{.Goodsid}}" class="buypage"><img src="{{.Imgsrc}}" alt="" class="mui-media-object" /></a>
							</li>
						{{end}}
					</ul>
				</div>
				<ul class="mui-table-view mui-table-view-chevron">

				</ul>
			</div>
		<!-- </div> -->

		<script src="../static/js/mui.min.js"></script>
		<script>
			mui.init({
				swipeBack: false, //启用右滑关闭功能


			});

			mui('#hotview').on('tap','.buypage',function(e){

				var a = this.getAttribute('id');
				// alert('http://192.168.80.105:8080/buypage?'+a);
				mui.openWindow({
					id:'gobuypage',
					url:'http://{{.ServerHost}}:{{.ServerPort}}/buypage?'+'goodsid='+a,
				})

			});

			//老式写法，因为要监听所有图片的动作，所以用on方法，监听所有假的.buypage并把goodsid传入
			// document.getElementById('buypage').addEventListener('tap',function(){
			// 	mui.openWindow({
			// 		id:'shop_car',
			// 		url:'http://192.168.80.105:8080/buypage',
			// 	});
			// });


			//图片轮播自动播放时间
			var slider = mui("#slider");
			slider.slider({
				interval: 3000
			});
		</script>
	</body>

</html>
